﻿
CREATE proc loadmenushowfinal
@UserID int,
@MaNhomUser int,
@MaChuongTrinh int,
@IDViTri int,
@MaNhomMenu int
as
declare @IdPhanNhomNguoiDung int
select @IdPhanNhomNguoiDung=ID from QuanTri_PhanNhomNguoiDung Where UserID=@UserID and MaNhomUser=@MaNhomUser
declare @IDCapQuyen int
select @IDCapQuyen=ID from QuanTri_CapQuyenNguoiDungSuDungMenu Where MaChuongTrinh=@MaChuongTrinh and IDViTri=@IDViTri
and MaNhomUser=@MaNhomUser and MaNhomMenuND=@MaNhomMenu

select c.TenMenu as MenuName,c.Hinh, 
cast(c.TenModule as nvarchar(200))+'.'+cast(c.TenThuMuc as nvarchar(200))+'.'+cast(c.TenForm as nvarchar(200))+'!!!!!'+          
c.TenForm+'%%%%%'+c.TenModule+'&&&&&'+cast(a.ID as nvarchar(200))+'^^^^^'+CAST(b.IDCN as nvarchar(200)) as ChuoiMenu,
b.Cap as CapMenu,b.MenuCha as MenuParent,b.MenuID as ID  ,b.ThuTuXuatHien       
from QuanTri_EditUserRoleInGroup a,QuanTri_PhanNhomMenu b,DanhMuc_Menu c
Where a.IDPhanNhomMenu=b.ID and b.MenuID=c.MenuID and a.IDPhanNhomNguoiDung=@IdPhanNhomNguoiDung and a.IDCapQuyen=@IDCapQuyen and b.MaNhomMenuND=@MaNhomMenu
and (a.Quyen_Xem=1  or a.Quyen_Xoa=1 or a.Quyen_CapNhat=1 ) 
order by b.ThuTuXuatHien  
